package com.datalayer.testclasses;

import com.datalayer.annotations.*;
import com.datalayer.utils.AssociationType;

/**
 * Created with IntelliJ IDEA.
 * User: Georgiana.Scarlat
 * Date: 7/6/12
 * Time: 4:30 PM
 */
@SuppressWarnings("ALL")
@Entity(tableName = "FUNCTIE")

public class Functie {

    int id;
    Angajat angajat;

    public Functie() {
    }

    public Functie(int id) {

        this.id = id;
    }

    @Direction("get")
    @Association(type = AssociationType.ON2ONE_REFERENCED, joins = {
            @Join(fieldName = "angajat", foreignName = "functie_fk", localAttribute = "id")})
    public Angajat getAngajat() {
        return angajat;
    }

    @Direction("get")
    @Constraint(constraintName = "primary key")
    @Attribute(fieldName = "id", attributeName = "id_functie", type = "int")
    public int getId() {
        return id;
    }

    @Direction("set")
    @Association(type = AssociationType.ON2ONE_REFERENCED, joins = {
            @Join(fieldName = "angajat", insideName = "id", foreignName = "functie_fk")})
    public void setAngajat(Angajat angajat) {
        this.angajat = angajat;
    }

    @Direction("set")
    @Attribute(fieldName = "id", attributeName = "id_functie", type = "int")
    public void setId(int id) {
        this.id = id;
    }

    @Override
    public String toString() {
        return "Functie{" +
                "angajat=" + angajat +
                ", id=" + id +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Functie functie = (Functie) o;

        if (id != functie.id) return false;

        return true;
    }

    @Override
    public int hashCode() {
        return id;
    }
}
